package com.hinnotek.warehouse.viewmodel

import androidx.lifecycle.Transformations
import com.google.gson.GsonBuilder
import com.hinnotek.warehouse.api.WarehouseApi
import com.hinnotek.warehouse.bean.WarehourseApplyFormDevicesProjects
import com.lee.common.network.getRequestBody
import com.lee.common.utils.PAGE_SIZE
import com.lee.common.utils.SharedPreUtils
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

/**
 * 设备使用情况
 */
@HiltViewModel
class DeviceUsageViewModel @Inject constructor() :
    BaseViewModel() {

    var productNum = ""

    private val deviceIfo = Transformations.switchMap(page) {
        //产品序号  productNum
        val map = mutableMapOf<String, Any>().apply {
            put("pageNo", it)
            put("pageSize", PAGE_SIZE)
            if (productNum != "")
                put("productNum", productNum)

        }
        api.getDeviceAccountUsePage(getRequestBody(map))
    }

    val deviceIfoPage = mapPage(deviceIfo)

}